﻿using System.Collections.Generic;
using System.ComponentModel;

namespace IntegratedMeasuring.ViewModels.Entity;
/// <summary>
/// author xxxxxx
/// </summary>
public static class GC
{
    /// <summary>
    /// 是否为PLC主控 
    /// </summary>
    ///  test
    public static bool IsPLCMainControl = true;
    
    public enum InstrumentModelType
    {
        TH2837AX = 0,
        TH2837AX48 = 1,
        TH2829LX = 2,
        TH2837LX = 3,
    }
    
    public enum LogLevel
    {
        INFO = 0,
        WARNING = 1,
        PRIMARY = 2,
        ERROR = 3,
    }
    
    public enum HenryUnit
    {
        nH,
        µH,
        mH,
        H,
    }
    
    public enum OhmUnit
    {
        nΩ,
        µΩ,
        mΩ,
        Ω,
        kΩ,
        MΩ,
    }
    
    public enum DuplicateCodeHandlingType
    {
        [Description("另存一条")]
        SaveAsNew = 0,   
        [Description("覆盖旧记录")]
        OverwriteOld = 1,
        [Description("弹框询问")]
        AskUser = 2
    }

    // 测试数据，测试文件，工单
    public static string BaseDbFilePath = GV.FilePath + "\\DB\\Basic.db";
    // 对基础数据库的增删改动作的记录, 及重要数据删除的备份
    public static string LogDbFilePath = GV.FilePath + "\\DB\\Log.db";
    
    public static Dictionary<int, InsComMeta> InstrumentModelTypeDict = new Dictionary<int, InsComMeta>()
    {
        {
            (int)InstrumentModelType.TH2837AX,
            new InsComMeta()
            {
                HandshakeCommand = "*IDN?",
                HandshakeReply = "Tonghui, TH2837AX,",
                TriggerTestCommand = "TRIG",
                PauseTestCommand = "",
                GetTestResultCommand = "trs:afet?",
                TestFileDataLength = 14336,
                ChannelCount = 20,
            }
        },
        {
            (int)InstrumentModelType.TH2837AX48,
            new InsComMeta()
            {
                HandshakeCommand = "*IDN?",
                HandshakeReply = "Tonghui, TH2837AX-48",
                TriggerTestCommand = "TRIG",
                PauseTestCommand = "",
                GetTestResultCommand = "trs:afet?",
                TestFileDataLength = 40960,
                ChannelCount = 48,
            }
        },
        {
            (int)InstrumentModelType.TH2829LX,
            new InsComMeta()
            {
                HandshakeCommand = "*IDN?",
                HandshakeReply = "Tonghui, TH2829LX",
                TriggerTestCommand = "TRIG",
                PauseTestCommand = "",
                GetTestResultCommand = "trs:afet?",
                TestFileDataLength = 14336,
                ChannelCount = 20,
            }
        },
        {
            (int)InstrumentModelType.TH2837LX,
            new InsComMeta()
            {
                HandshakeCommand = "*IDN?",
                HandshakeReply = "Tonghui, TH2837LX",
                TriggerTestCommand = "TRIG",
                PauseTestCommand = "",
                GetTestResultCommand = "trs:afet?",
                TestFileDataLength = 14336,
                ChannelCount = 20,
            }
        }
    };

}

// 仪器通讯信息定义
public class InsComMeta {
    // 握手命令
    public string HandshakeCommand { get; set; } = string.Empty;
    // 握手回复
    public string HandshakeReply { get; set; } = string.Empty;
    // 触发测试
    public string TriggerTestCommand { get; set; } = string.Empty;
    // 暂停测试
    public string PauseTestCommand { get; set; } = string.Empty;
    // 获取测试结果
    public string GetTestResultCommand { get; set; } = string.Empty;
    // 测试文件数据长度
    public int TestFileDataLength { get; set; } = 0;
    // 通道数
    public int ChannelCount { get; set; } = 20;
}